package com.mini.mybatis.mapping;

import com.mini.mybatis.type.JdbcType;
import com.mini.mybatis.type.TypeHandler;

/**
 * 参数映射 - 封装SQL参数的映射信息
 */
public class ParameterMapping {
    
    private String property;
    private Class<?> javaType;
    private JdbcType jdbcType;
    private TypeHandler<?> typeHandler;
    
    private ParameterMapping() {
    }
    
    /**
     * 获取属性名
     */
    public String getProperty() {
        return property;
    }
    
    /**
     * 获取Java类型
     */
    public Class<?> getJavaType() {
        return javaType;
    }
    
    /**
     * 获取JDBC类型
     */
    public JdbcType getJdbcType() {
        return jdbcType;
    }
    
    /**
     * 获取类型处理器
     */
    public TypeHandler<?> getTypeHandler() {
        return typeHandler;
    }
    
    /**
     * 参数映射构建器
     */
    public static class Builder {
        
        private ParameterMapping parameterMapping = new ParameterMapping();
        
        public Builder(String property, Class<?> javaType) {
            parameterMapping.property = property;
            parameterMapping.javaType = javaType;
        }
        
        public Builder jdbcType(JdbcType jdbcType) {
            parameterMapping.jdbcType = jdbcType;
            return this;
        }
        
        public Builder typeHandler(TypeHandler<?> typeHandler) {
            parameterMapping.typeHandler = typeHandler;
            return this;
        }
        
        public ParameterMapping build() {
            return parameterMapping;
        }
    }
}